package com.zds.mydatabinding;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.zds.mydatabinding.databinding.ActivityMainBinding;
import com.zds.mydatabinding.glide.GlideActivity;
import com.zds.mydatabinding.photoview.PhotoviewActivity;
import com.zds.mydatabinding.rxjava.Rxjava2Activity;
import com.zds.mydatabinding.rxjava.RxjavaActivity;

public class MainActivity extends AppCompatActivity {
    private ActivityMainBinding mainBinding;
    private Student student;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initData();
        initLisenter();
    }

    private void initData(){
        mainBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
        student = new Student("狼王","0");
        mainBinding.setStudent(student);
    }

    private void initLisenter(){
        mainBinding.btnChange.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                student.setAge("15");
                student.setMame("网龙");
                startActivity(new Intent(MainActivity.this,Rxjava2Activity.class));
            }
        });
    }
}
